package com.flyan.game.motafx.effect.terrain;

import com.almasb.fxgl.entity.Entity;
import com.flyan.game.motafx.core.enums.EntityTypeEnum;
import com.flyan.game.motafx.core.panel.GameInfoPanel;
import com.flyan.game.motafx.core.util.core.GameUtils;
import com.flyan.game.motafx.effect.BaseEffect;
import javafx.util.Duration;
import org.jetbrains.annotations.NotNull;

/**
 * 楼梯效果
 *
 * @author flyan
 * @version 1.0
 * @email flyan_by_chenu@sina.com
 * @since 2025/2/7
 */
public class StairEffect extends BaseEffect {

    public StairEffect() {
        /* 无限时间，上楼完成后人物移动后才会结束 */
        super(Duration.INDEFINITE);
        setAllowRepeat(false); // 不允许重复添加
    }

    @Override
    public void onStart(@NotNull Entity entity) {
        EntityTypeEnum terrainType = (EntityTypeEnum) triggerEntity.getType();
        switch (terrainType) {
            case TERRAIN_UP_STAIRS -> GameUtils.app().towerMap.upFloor();
            case TERRAIN_DOWN_STAIRS -> GameUtils.app().towerMap.downFloor();
        }
        GameInfoPanel.redraw();
    }

    @Override
    public void onEnd(@NotNull Entity entity) {

    }

}
